<template>
  <div class="receipt-wrap">
    <div class="receipt-header">
      <p>订单回执</p>
    </div>
    <div class="receipt-main">
    <!--   地址    -->
      <div class="receipt-address">
        <div>
          <img src="https://img.wifenxiao.com/h5-wfx/images/DZ/changjunhai/ding.png">

        </div>
        <div>
          <p v-html="address"></p>
          <p>订单已提交。截单后将无法修改信息</p>
        </div>
      </div>
    <!--   商品   -->
      <div class="receipt-goods">
        <p class="orderNum">订单编号：{{purchase_number}}</p>
        <div class="receipt-goods-main" v-for="(item, index) in goodsData" :key="index">
          <div class="goods-img">
            <img :src="item.img">
          </div>
          <div class="goods-name">
            <p>{{item.title}}</p>
            <p><span v-if="item.props">{{item.props}}</span></p>
            <p>
              <span v-html="scaleGoodsPriceFn(item.price)"></span>
              <span>x{{item.num}}</span>
            </p>
          </div>
        </div>
        <div class="receipt-goods-money">
          <p><span>商品金额：</span><span v-html="scaleGoodsPriceFn(totalMoney)"></span></p>
          <p><span>运费：</span><span v-html="scaleGoodsPriceFn(post_fee)"></span></p>
        </div>
        <div class="receipt-goods-hj">
          <p>
            <span>合计：</span>
            <span v-html="scaleGoodsPriceFn(Number(totalMoney) + Number(post_fee))"></span>
          </p>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import { scaleGoodsPrice } from '@/utils/index'
import { purchaseReceipt } from '@/api/dz/dzCcbd'
export default {
  data() {
    return {
      purchase_id: undefined,
      goodsData: [],
      address: undefined,
      purchase_number: undefined,
      totalMoney: 0,
      post_fee: 0
    }
  },
  created() {
    this.purchase_id = this.$route.query.purchase_id
    this.init()
  },
  methods: {
    init() {
      // console.log('aaa')
      purchaseReceipt({ purchase_id: this.purchase_id }).then(res => {
        // console.log(res)
        this.goodsData = res.itemList
        this.purchase_number = res.purchase_number
        this.address = res.remark // 地址
        this.post_fee = res.post_fee // 运费
        this.totalMoney = res.totalMoney // 总金额
      })
    },
    scaleGoodsPriceFn(price, className) {
      return scaleGoodsPrice(price, className)
    }
  }
}
</script>

<style lang="scss">
  .receipt-wrap{
    width: 100%;
    .receipt-header{
      width: 100%;
      height: 200px;
      background: linear-gradient(to right, #F30C23, #FE224E);
      p{
        text-align: center;
        font-size: 30px;
        font-weight: bold;
        color: white;
        line-height: 100px;
      }
    }
    .receipt-main{
      width: calc(100% - 40px);
      height: 800px;
      margin: -80px auto 0 auto;
      .receipt-address{
        width: 100%;
        min-height: 200px;
        background-color: white;
        border-radius: 10px;
        overflow: hidden;
        div:nth-child(1){
          width: 140px;
          height: 140px;
          background: linear-gradient(to right, #F30C23, #FE224E);
          border-radius: 5px;
          float: left;
          margin: 30px 0 30px 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          img{
            width: 65px;
            height: 75px;
          }
        }
        div:nth-child(2){
          width: 500px;
          float: left;
          margin: 30px 0 30px 20px;
          color: #333;
          font-weight: 500;
          font-size: 26px;
          p:nth-child(1){
            margin-top: 10px;
            line-height: 35px;
          }
          p:nth-child(2){
            font-weight: 400 !important;
            font-size: 20px !important;
            color: #DEAD6F;
            margin-top: 10px;
          }
        }
      }
      .receipt-goods{
        width: 100%;
        min-height: 200px;
        background-color: white;
        border-radius: 10px;
        overflow: hidden;
        margin-top: 20px;
        padding: 30px;
        padding-top: 0;
        .orderNum{
          line-height: 80px;
          color: #333333;
          font-size: 28px;
          font-weight: bold;
          border-bottom: 1px solid #EDEDEDc3;
        }
        .receipt-goods-main{
          margin-top: 20px;
          overflow: hidden;
          padding-bottom: 10px;
          border-bottom: 1px solid #EDEDEDc3;
          .goods-img{
            width: 180px;
            height: 180px;
            float: left;
            img{
              width: 100%;
              height: 100%;
              border-bottom: 6px;
            }
          }
          .goods-name{
            margin-left: 15px;
            float: left;
            width: 450px;
            p:nth-child(1){
              font-weight: 500;
              display: -webkit-box;
              -webkit-line-clamp: 2;
              -webkit-box-orient: vertical;
              white-space: inherit;
              word-break: break-all;
              text-overflow: ellipsis;
              overflow: hidden;
              font-size: 26px;
            }
            p:nth-child(2){
              margin-top: 15px;
              font-size: 24px;
            }
            p:nth-child(3){
              margin-top: 15px;
              font-size: 22px;
              display: flex;
              justify-content: space-between;
              span:nth-child(1){
                color: #f30c23;
                font-size: 30px;
              }
            }
          }
        }
        .receipt-goods-money{
          width: 100%;
          height: 120px;
          border-bottom: 1px solid #EDEDED;
          overflow: hidden;
          padding: 20px 0 20px 0;
          p{
            color: #333;
            font-size: 28px;
            display: flex;
            justify-content: space-between;
            span:nth-child(2){
              color: #f30c23;
            }
          }
          p:nth-child(1){
          }
          p:nth-child(2){
            margin-top: 10px;
          }
        }
        .receipt-goods-hj{
          line-height: 80px;
          text-align: right;
          p{
            span:nth-child(1){
              font-size: 30px;
              font-weight: bold;
            }
            span:nth-child(2){
              font-size: 28px;
              color: #f30c23;
            }
          }
        }
      }
    }
  }

</style>
